package com.tuo51.foudation.exception;

import lombok.Getter;

import javax.validation.constraints.NotNull;

/**
 * *******************************
 * Created by Ron.
 * form com.tuo51
 * on 2017/5/15
 * *******************************
 */
@Getter
public class BusinessException extends RuntimeException{

    private String errorCode;

    public BusinessException(String errorCode) {
        this(errorCode, null, null);
    }

    public BusinessException(String errorCode, String message) {
        this(errorCode, message, null);
    }

    public BusinessException(String errorCode,
                             @NotNull Throwable cause) {
        this(errorCode, null, cause);
        this.errorCode = errorCode;
    }

    public BusinessException(String errorCode, String message,
                             Throwable cause) {
        super(message, cause);
        this.errorCode = errorCode;
    }

    @Override
    public String toString() {
        return errorCode + " : " + super.toString();
    }
}
